package com.haixiaoke.oss.controller;

import com.haixiaoke.common.core.domain.AjaxResult;
import com.haixiaoke.common.oss.service.OSSService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 阿里云OSS对象存储
 * 
 * @author shun
 * @createDate: 2021年3月24日 下午4:48:05
 * @version: 1.0
 *
 */
@Controller
@RequestMapping("/oss")
public class OSSController {
	@Autowired
	private OSSService ossService;

	/**
	 * 文件上传
	 *
	 * @param type
	 * @return
	 * @author shun
	 * @date 2021年3月24日
	 */
	@PostMapping(value = "/file/{type}")
	@ResponseBody
	public AjaxResult putFile(@RequestParam("file") MultipartFile file, @PathVariable String type) {
		return AjaxResult.success(ossService.putFile(null, file, type));
	}

	@PostMapping(value = "/face/file/{type}")
	@ResponseBody
	public AjaxResult facePutFile(@RequestParam("file") MultipartFile file, @PathVariable String type) {
		return AjaxResult.success(ossService.putFile(null, file, type));
	}



}
